import java.util.Arrays;
import java.util.ArrayList;

public class Main {
    public static int[] solution(int n){
        ArrayList<Integer> list = new ArrayList<>();
        for (int i = 1; i < n+1; i++) {
            for(int j = n; j >= i; j--){
                list.add(j);
            }
        }

        int[] array = new int[list.size()];
        for (int i = 0; i < list.size(); i++) {
            array[i] = list.get(i);
        }

        return array;
    }

    public static void main(String[] args){
        System.out.println(Arrays.equals(solution(3), new int[]{3, 2, 1, 3, 2, 3}));
        System.out.println(Arrays.equals(solution(4), new int[]{4, 3, 2, 1, 4, 3, 2, 4, 3, 4}));
        System.out.println(Arrays.equals(solution(5), new int[]{5, 4, 3, 2, 1, 5, 4, 3, 2, 5, 4, 3, 5, 4, 5}));
    }

}
